package com.study.concurrent;

/**
 * Description:
 * User: 27010
 * DateTime: 2018/6/10 23:02
 */
public class VolatileTest {
    private volatile User user;
    private volatile int[] array = new int[100];

    public void changeUser(User user) {
        this.user = user;
    }
    public void changeArray(int[] array) {
        this.array = array;
    }

    //能否保证可见性
    public void changeUserName(String name) {
        this.user.setName(name);
    }
    public void changeArrayOneValue(int index, int value) {
        this.array[index] = value;
    }

    class User {
        private int age;
        private String name;

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
